package com.fy.oa.zc.controller;

import java.io.PrintWriter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.servlet.ModelAndView;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fy.oa.zc.manager.FyOA_CommQueryManager;
import com.fy.oa.zc.manager.FyOA_CommQueryResultBean;
import com.seeyon.ctp.common.controller.BaseController;

public class Fy_OAController extends BaseController {
	private FyOA_CommQueryManager fyOA_CommQueryManager;

	public void setFyOA_CommQueryManager(FyOA_CommQueryManager fyOA_CommQueryManager) {
		this.fyOA_CommQueryManager = fyOA_CommQueryManager;
	}

	public ModelAndView commQuery(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String name = request.getParameter("name");
		String[] args = request.getParameterValues("args");
		FyOA_CommQueryResultBean queryResult = fyOA_CommQueryManager.query(name, args);
		ObjectMapper om = new ObjectMapper();
		PrintWriter writer = response.getWriter();
		writer.write(om.writeValueAsString(queryResult));
		writer.flush();
		writer.close();
		return null;
	}
}
